<template>
  <div class="wrapper">
    <el-dialog title="成本控制" custom-class="dialogStyle" :visible.sync="showDialog" :before-close="handleClose"
      append-to-body>
      <el-alert :title="overWarning" type="warning">
      </el-alert>
      <el-table :data="tableData" style="width: 100%;margin-top: 5px;" :header-cell-style="{ 'text-align': 'center' }" default-expand-all
        class="required-table">
        <el-table-column prop="waybill_no" label="运单号" width="120" align="right">
        </el-table-column>
        <el-table-column prop="excess_limit" label="超出费用" width="150" align="center">
        </el-table-column>
        <el-table-column prop="reason" label="超出原因" align="center">
          <template #header>
            <div>
              <span style="color: red">*</span> <span>超出原因</span>
            </div>
          </template>
          <template slot-scope="scope">
            <el-input type="textarea" :autosize="{ minRows: 1, maxRows: 4 }" v-model="scope.row['reason']"></el-input>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="handleOk">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'costControl',
  components: {},
  props: ["showDialog", 'tableData', 'overWarning'],
  data() {
    return {
    };
  },
  mounted() {
    console.log('11111111')
   },
  methods: {
    handleOk() {
      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].reason == '') {
          this.$message({
            message: "请填写费用超出原因",
            type: "warning",
          });
          return;
        }
      }
      this.$emit('ok', this.tableData);
    },
    handleClose() {
      this.$emit('close');
    }
  },
};
</script>
<style lang="scss" scoped>
.wrapper {}

/deep/.dialogStyle {
  width: 600px;
}
</style>